package IO.io_5_9;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * @author bruin_du
 * @description 测试读取文件
 * @date 2022/5/12 14:46
 **/
public class ReadTest {
    // 文本文件的读取方式
    public static void main(String[] args) throws IOException {
        try (InputStream is = new FileInputStream("hello.txt")) {
            Scanner scanner = new Scanner(is, "GBK");
            // 读到下一个空格或者回车
            while (scanner.hasNext()) {
                System.out.println(scanner.next());
            }
        }
    }
}
